// const app = getApp();
export const setStorageFormUserInfoAndGopage = function (userInfo, that) { //这个函数在fetchUserInfoFromBackendFlowAtMypage中调用
  var school = userInfo["school"];
  console.log(school);
  wx.setStorageSync("school", school);
  switch (userInfo['role']) {
    case 0:
      var name = userInfo["name"];
      var teacher_id = userInfo["userid"];
      wx.setStorageSync("teacher_id", teacher_id);
      wx.setStorageSync('role', '1');
      wx.setStorageSync("name", name);
      // that.goTeacher();
      wx.redirectTo({
        url: '/page/teacher/page/three/three',
      })
    case 1:
      var name = userInfo["name"];
      wx.setStorageSync("name", name);
      var teacher_id = userInfo["userid"];
      wx.setStorageSync("teacher_id", teacher_id);
      wx.setStorageSync('role', '任课老师');
      // that.goClass();
      wx.redirectTo({
        url: '/page/teacher/page/three/three',
      })
    default:
      var s_class = userInfo["s_class"];
      var student_id = userInfo["userid"];
      var room = userInfo["room"];
      var name = userInfo["name"];
      //添加学生信息到本地缓存，在退出时记得释放
      wx.setStorageSync("s_class", s_class);
      wx.setStorageSync("name", name);
      wx.setStorageSync("room", room);
      wx.setStorageSync("student_id", student_id);
      // that.goStudent();
      wx.redirectTo({
        url: '/page/teacher/page/three/three',
      })
  }
  wx.showToast({
    title: '登录成功',
    icon: 'success',
    duration: 3000
  })
}